<!DOCTYPE html>
<html>
<head>
<base href="<?php echo XXF_HTTP?>" />
<meta charset="utf-8">
<title>评教系统</title>
<style type="text/css">
*{margin:0;padding:0;cursor:pointer;}
.xuanxiang:hover{
	background-color:#bbb;
}
</style>
</head>
<body>
<div style="position:fixed; top:0; left: 0;width:100%; height:48px; background:#b5e61d;padding-top:5px;">
	<div style="width:200px;margin:0 auto;color:red;font-weight:bold;">全部教师评完后，点击此按钮提交评价表。<input onclick="sub()" type="button" value="   提  交   "></div>
</div>
<div style="width:700px;margin:53px auto;">
    <?php
    $pj=xdb::getInstance()->getrow("select * from pingjiao where id=$pjid");
    $sj=xdb::getInstance()->getrow("select * from pingceshijuan where id=".$pj['pcsjid']);
	$pcsjt=xdb::getInstance()->getarray("select * from pingceshijuantitle where pcsjid =".$sj['id']);
	$j=0;
    foreach ($result as $row){
        $j++;
    ?>
    <div style="width: 100%;border:2px solid #000;margin-top:15px;padding: 10px;background-color:#eee;">
    	<div style="text-align: center;">
    	<?php echo $pj['pjname']?>
    	<br><br>
		评测班级：<font size="6"><?php echo $cname?></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		评测对象：<font size="6"><?php echo $row['tname']?></font>
		</div>
		<hr>
		<?php 
		$i=0;
		foreach ($pcsjt as $tr){
		    $i++;
		    echo '<div id="d_'.$row['id'].'_'.$tr['id'].'" style="background-color:#FFFFFF;">';
		    echo $i."、".$tr['title'];
		    echo '<br>';
		    $pjxx=xdb::getInstance()->getarray("select * from pingceshijuansub where pcsjtid=".$tr['id']);
		    foreach ($pjxx as $xx){
		        echo '&nbsp;&nbsp;&nbsp;<input type="radio" name="r_'.$row['id'].'_'.$tr['id'].'" value="'.$xx['fen'].'" id="r_'.$row['id'].'_'.$tr['id'].'_'.$xx['id'].'"  onclick="sel(\'d_'.$row['id'].'_'.$tr['id'].'\')">';
		        echo '<label for="r_'.$row['id'].'_'.$tr['id'].'_'.$xx['id'].'">'.$xx['sub'];
		        echo '<br>';
		    }
		    echo '<hr style="border:1px solid #eee;margin-bottom:5px;">';
		    echo "</div>";
		}
		?>
		对他（她）的评价：<input type="text" style="width: 500px;" id="t_<?php echo $row['id']?>">
	</div>
    <?php 
    }
    ?>
</div>
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/jquery.xxfset.js?r=<?php echo rand()?>"></script>
<script type="text/javascript">
function sub(){
	$radiochecked=$("input[type='radio']:checked");
	if($radiochecked.length!=<?php echo $i*$j?>){
		alert("还有评测题目没有答，请检查并将所有题目答完后再试！");
	}else{
		$pjoids=[<?php 
		foreach ($result as $row){
		    echo "'".$row['id']."',";
		}
		?>];
		$now="<?php echo date("Y-m-d H:i:s", time()+12*60*60);?>";
		$result={};
		for($id of $pjoids){
			temcontent="pjcontent";
			temfen=0;
			$pjcontent=$("[id^='r_"+$id+"_']:checked");
			$.each($pjcontent,function(k,v){
				temcontent+=","+v.id;
				temfen+=parseFloat(v.value);
			});
			$result["pjoid_"+$id]={
				pjcontent:temcontent,
				fen:temfen,
				beizhu:$("#t_"+$id).val()
			}
		}
		$.xpost("pingce",{
			type:"pingceresult",
			stime:$now,
			result:$result
		},function(data){
			$.xloading(0);
			if(data==1){
				$.xalert("你已完成测评，可以离开了，谢谢你的参与！",function(){
					location.href="sjpj";
				});
			}else{
				console.log(data);
			}
		});
	}
}
function sel(id){
	var ele=document.getElementById(id);
	ele.style.backgroundColor="#b5e61d";
}
</script>
</body>
</html>